package com.microboot.client;

import com.microboot.interceptor.ClientLoginInterceptor;
import com.microboot.service.user.dao.IMessageService;
import lombok.extern.slf4j.Slf4j;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;


@Slf4j
public class CXFClientProxy {

    public static void main(String[] args) {
        //WebService服务地址
        String address = "http://localhost:8080/services/MessageService?wsdl";

        JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
        jaxWsProxyFactoryBean.setAddress(address); //代理地址
        jaxWsProxyFactoryBean.setServiceClass(IMessageService.class); //映射的接口
        jaxWsProxyFactoryBean.getOutInterceptors()
                .add(new ClientLoginInterceptor("longxian","root123"));//设置认证账户信息
        IMessageService messageService = (IMessageService) jaxWsProxyFactoryBean.create(); //远程接口映射
        String message = "测试调用数据是否成功(success)";
        String result = messageService.echo(message);
        log.info("CXFClientProxy 调用服务接口返回数据信息为：{}",result);
    }
}
